home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / asmexam.arc / PASSWORN.LST < prev    next >
Encoding:
File List  |  1983-11-17  |  13.1 KB  |  279 lines

  1.  The Microsoft MACRO Assembler             11-17-83        PAGE    1-1
  2.  
  3.  
  4.  
  5.                             page 55,132
  6.                     ;------------------------------------------------------------------------------
  7.                     ;PASSWORD.ASM (creates PWORD.SYS, device driver)
  8.                     ;
  9.                     ;DOS 2.00 Device driver forces user to enter password on booting up
  10.                     ;and disables Ctrl-Break.
  11.                     ;
  12.                     ;After assembly: link PASSWORD (ignore "no STACK" error)
  13.                     ;                exec2bin PASSWORD PASSWORD.SYS
  14.                     ;                place DEVICE=PASSWORD.SYS in CONFIG.SYS file
  15.                     ;                reboot system with Ctrl-Alt-Del
  16.                     ;                answer prompt with: PassWord <enter>
  17.                     
  18.  0000                   dev_seg segment
  19.  0000                   pword_device proc far
  20.                                   assume cs:dev_seg,ds:dev_seg,es:dev_seg
  21.                     
  22.                     ;-------------------------------
  23.                     ;The following lines are the device header, which must exist for
  24.                     ;every device.  This file has only one device, and it works with
  25.                     ;character I/O.  It doesn't actually handle any I/O services,
  26.                     ;but it's easier to create a character device.
  27.                     
  28.  0000                   pword_dev_header:   ;label for the start of the device driver
  29.                     
  30.  0000  FF FF FF FF         next_dev_ptr       dd -1               ;only 1 device is defined in this file
  31.  0004  8000              dev_attribute      dw 8000h            ;character device (simpler that way)
  32.  0006  0070 R              strategy_ptr       dw  strategy        ;the installation proc
  33.  0008  007B R              interrupt_ptr      dw  interrupt       ;the proc that handles all service requests
  34.  000A  50 41 53 53 57 4F    device_name        db  'PASSWORD'      ;8-byte string of device name
  35.        52 44              
  36.                     
  37.                     ;--- This is the stroage area for the password --
  38.                     ;--- The first byte is the length (0-16) --------
  39.                     ;--- The following characters are the password --
  40.                     ;--- Only an exact match will allow the system --
  41.                     ;--- to continue the boot process ---------------
  42.                     
  43.  0012  08 50 61 73 73 57    password_store     db 8,'PassWord'
  44.        6F 72 64              
  45.  001B     09 [                                 db $-password_store dup(' ')       ;leave room for a
  46.                 20         
  47.                     ]         
  48.                     
  49.                                                                           ;16 character password
  50.                     
  51.  0024  10              in_buf_max db 16        ;input buffer for reading password from user
  52.  0025  ??              in_buf_len db ?         ;it is set up for DOS service OAH, BUFFERED_INPUT
  53.  0026     10 [              in_buf     db 16 dup(?)
  54.                 ??         
  55.  The Microsoft MACRO Assembler             11-17-83        PAGE    1-2
  56.  
  57.  
  58.  
  59.                     ]         
  60.                     
  61.                     
  62.                     ;----- The STRATEGY proc stores ES:BX request header pointer here
  63.                     ;----- The INTERRUPT proc retrieves it
  64.                     
  65.  0036                   request_ptr label dword                ;defined as double word for LES opcode
  66.  0036  ????              req_ptr_off dw  ?                      ;and as two words for MOV opcodes
  67.  0038  ????              req_ptr_seq dw  ?
  68.                     
  69.                     
  70.                     
  71.  003A                   dummy_iret:                            ;Ctrl-Break vector is pointed here, so it
  72.  003A  CF                                 IRET                ;does nothing.  Break is not recognized.
  73.                     
  74.                     ;------------------messages----------------------------------------------------
  75.                     ;These messages are expected to be output via the ANSI.SYS device,
  76.                     ;so it should be installed (named in the CONFIG.SYS file) before
  77.                     ;this PWORD device.
  78.                     ;If you don't want to use ANSI.SYS, remove the ESC sequences in the messages.
  79.                     
  80.  = 000A                   lf equ 0ah
  81.  = 000D                   cr equ 0dh
  82.  = 001B                   esc equ 1bh
  83.                     
  84.  003B  0D 0A 1B 5B 30 6D    msg_1              db cr,lf,esc,'[0m'                 ;make output visible
  85.  0041  45 6E 74 65 72 20                       db 'Enter Password: '
  86.        50 61 73 73 77 6F    
  87.        72 64 3A 20         
  88.  0051  1B 5B 38 6D 24                            db esc,'[8m$'                     ;make input invisible
  89.                     
  90.  0056  0D 0A 1B 30 6D         msg_2              db cr,lf,esc,'0m'                  ;make output visible
  91.  005B  50 61 73 73 77 6F                       db 'Password accepted.',cr,lf,'$'
  92.        72 64 20 61 63 63    
  93.        65 70 74 65 64 2E    
  94.        0D 0A 24              
  95.                     
  96.                     ;==============================================================================
  97.                     ;STRATEGY procedure
  98.                     ;Just saves the request header pointer for the INTERRUPT proc
  99.                     
  100.  0070                   strategy proc far
  101.                                        assume cs:dev_seg
  102.  0070  2E: 89 1E 0036 R                            mov  cs:req_ptr_off,bx
  103.  0075  2E: 8C 06 0000 U                            mov  cs:req_ptr_seg,es
  104.  E r r o r   ---    9:Symbol not defined            
  105.  007A  CB                                 ret                                ;far return to DOS
  106.  007B                   strategy endp
  107.                     
  108.                     ;==============================================================================
  109.  The Microsoft MACRO Assembler             11-17-83        PAGE    1-3
  110.  
  111.  
  112.  
  113.                     ;INTERRUPT procedure
  114.                     ;Processes the command indicated in the request header.
  115.                     
  116.  007B                   interrupt proc far
  117.                                        assume cs:dev_seg,ds:nothing, es:nothing
  118.  007B  1E                                 push       ds                      ;preserve all registers
  119.  007C  06                                 push       es
  120.  007D  50                                 push       ax
  121.  007E  53                                 push       bx
  122.  007F  51                                 push       cx
  123.  0080  52                                 push       dx
  124.  0081  57                                 push       di
  125.  0082  56                                 push       si
  126.  0083  8C C8                                 mov        ax,cs                   ;make DS address the
  127.  0085  8E D8                                 mov        ds,ax                   ;program data area
  128.                     
  129.  0087  2E: C4 1E 0036 R                            les        bx,request_ptr          ;get the pointer saved by STATEGY
  130.  008C  26: 8A 47 02                            mov        al,es:[bx+2]            ;fetch the command
  131.  0090  3C 00                                 cmp        al,0
  132.  0092  74 14                                 je         init_fn                 ;only valid request in INIT_FN
  133.  0094                   error_exit:
  134.  0094  26: 81 4F 03 8003                       or         word ptr es:[bx+3],8003H       ;indicate error code 3:
  135.                                                                                  ;"Unknown command"
  136.                     
  137.                     ;---- interrupt service request has been handled.
  138.                     ;---- Set he "done flag" and return to DOS.
  139.                     
  140.  009A                   common_exit:
  141.  009A  26: 81 4F 03 0100                       or         word ptr es:[bx+3],100H        ;set the done bit
  142.  00A0  5E                                 pop        si
  143.  00A1  5F                                 pop        di
  144.  00A2  5A                                 pop        dx
  145.  00A3  59                                 pop        cx
  146.  00A4  5B                                 pop        bx
  147.  00A5  58                                 pop        ax
  148.  00A6  07                                 pop        es
  149.  00A7  1F                                 pop        ds
  150.  00A8                                      ret                 :far return
  151.  E r r o r   ---    10:Syntax error                  
  152.                     
  153.                     ;---- Only the INIT function is handled by the PWORD device
  154.                     ;---- all other requests are routed through the error_exit.
  155.                     
  156.                     ;----------------------------------
  157.                     ;INIT_FN procedure
  158.                     ;prompts the user for a password, keeps prompting until correct entry
  159.                     ;received,  Passes the address of this proc back to DOS as the end-of-driver
  160.                     ;address so that a minimum amount of storage is used.
  161.                     
  162.  00A8                   init_fn proc near
  163.  The Microsoft MACRO Assembler             11-17-83        PAGE    1-4
  164.  
  165.  
  166.  
  167.                     
  168.  00A8  06                                 push       es
  169.                     
  170.                     ;--------------
  171.                     ;The following 4 lines eliminate Ctrl-Break from having
  172.                     ;any effect on the system, unless another program
  173.                     ;KEYBOARD_BREAK vector is altered (BASIC does that).
  174.                     
  175.  00A9  B8 0000                                 mov        ax,0
  176.  00AC  8E C0                                 mov        es,ax
  177.  00AE  26: C7 06 006C 003A R                       mov        word ptr es:[1Bh*4],offset dummy_iret
  178.  00B5  26: 8C 0E 006E                            mov        word ptr es:[1Bh*4+2],cs
  179.  00BA  EB 06                                 jmp        short no_beep
  180.  00BC                   try_again:
  181.  00BC  B0 07                                 mov        al,7     ;bel character
  182.  00BE  B4 0E                                 mov        ah,0EH   ;WRITE_TTY service
  183.  00C0  CD 10                                 int        10h
  184.  00C2                   no_beep:
  185.  00C2  BA 003B R                            mov        dx,offset msg_1         ;"Enter Password:"
  186.  00C5  B4 09                                 mov        ah,9                    ;DOS print string service
  187.  00C7  CD 21                                 int        21H
  188.                     
  189.  00C9  BA 0024 R                            mov        dx,offset in_buf_max
  190.  00CC  B4 0C                                 mov        ah,0Ch                  ;clear input buffer and..
  191.  00CE  B0 0A                                 mov        al,0Ah                  ;input a line of characters
  192.  00D0  CD 21                                 int        21H
  193.  00D2  8C C8                                 mov        ax,cs
  194.  00D4  8E C0                                 mov        es,ax                   ;set ES to target password for DMPSB
  195.                                                                           ;DS already points to user input
  196.  00D6  BE 0000 U                            mov        si,offset in_buf_store
  197.  E r r o r   ---    9:Symbol not defined            
  198.  00D9  B5 00                                 mov        ch,0
  199.  00DB  8A 0C                                 mov        cl,[si]
  200.  00DD  3A 0D                                 cmp        cl,[di]                 ;are lengths the same?
  201.  00DF  75 DB                                 jne        try_again
  202.  00E1  47                                 inc        di                      ;point to first characters
  203.  00E2  46                                 inc        si                      ;of both strings
  204.  00E3  F3/ A6                                 rep cmpsb                          ;all chars the same?
  205.  00E5  75 D5                                 jne        try_again               ;no, start over
  206.                     
  207.  00E7  BA 0056 R                            mov        dx,offset msg_2 ;"Password accepted"
  208.  00EA  B4 09                                 mov        ah,9
  209.  00EC  CD 21                                 int        21H
  210.                     
  211.                     ;---- now exit from INIT procedure -----------------------------
  212.                     ;---- retain only the minimum amount of code -------------------
  213.                     ;---- to handle erroneous service requests ---------------------
  214.                     
  215.  00EE  07                                 pop        es
  216.  00EF  26: C7 87 0000 U 00A8 R                       mov        word ptr es:[bx+OEH],offset init_fn ;end is at this proc
  217.  E r r o r   ---    9:Symbol not defined            
  218.  The Microsoft MACRO Assembler             11-17-83        PAGE    1-5
  219.  
  220.  
  221.  
  222.  00F6  26: 8C 8F 0001 U                            mov        word ptr es:[bx+1OH],cs        ;segment is at current CS
  223.  E r r o r   ---    9:Symbol not defined            
  224.                     
  225.  00FB  EB 9D                                 jmp        common_exit
  226.  00FD                   init_fn            endp
  227.                     
  228.  00FD                   interrupt endp
  229.  00FD                   pword_device endp
  230.  00FD                   dev_seg ends
  231.                                        end        pword_dev_header        ;must specify end for EXE2BIN
  232.  
  233.  The Microsoft MACRO Assembler             11-17-83        PAGE    Symbols-1
  234.  
  235.  
  236.  
  237. Segments and groups:
  238.  
  239.          N a m e              Size    align    combine    class
  240.  
  241. DEV_SEG. . . . . . . . . . . . .    00FD    PARA      NONE    
  242.  
  243. Symbols:            
  244.  
  245.          N a m e              Type    Value    Attr         
  246.  
  247. COMMON_EXIT. . . . . . . . . . .    L NEAR     009A    DEV_SEG
  248. CR . . . . . . . . . . . . . . .    Number    000D    
  249. DEVICE_NAME. . . . . . . . . . .    L BYTE     000A    DEV_SEG
  250. DEV_ATTRIBUTE. . . . . . . . . .    L WORD     0004    DEV_SEG
  251. DUMMY_IRET . . . . . . . . . . .    L NEAR     003A    DEV_SEG
  252. ERROR_EXIT . . . . . . . . . . .    L NEAR     0094    DEV_SEG
  253. ESC. . . . . . . . . . . . . . .    Number    001B    
  254. INIT_FN. . . . . . . . . . . . .    N PROC    00A8    DEV_SEG    Length =0055
  255. INTERRUPT. . . . . . . . . . . .    F PROC    007B    DEV_SEG    Length =0082
  256. INTERRUPT_PTR. . . . . . . . . .    L WORD     0008    DEV_SEG
  257. IN_BUF . . . . . . . . . . . . .    L BYTE     0026    DEV_SEG    Length =0010
  258. IN_BUF_LEN . . . . . . . . . . .    L BYTE     0025    DEV_SEG
  259. IN_BUF_MAX . . . . . . . . . . .    L BYTE     0024    DEV_SEG
  260. LF . . . . . . . . . . . . . . .    Number    000A    
  261. MSG_1. . . . . . . . . . . . . .    L BYTE     003B    DEV_SEG
  262. MSG_2. . . . . . . . . . . . . .    L BYTE     0056    DEV_SEG
  263. NEXT_DEV_PTR . . . . . . . . . .    L DWORD    0000    DEV_SEG
  264. NO_BEEP. . . . . . . . . . . . .    L NEAR     00C2    DEV_SEG
  265. PASSWORD_STORE . . . . . . . . .    L BYTE     0012    DEV_SEG
  266. PWORD_DEVICE . . . . . . . . . .    F PROC    0000    DEV_SEG    Length =00FD
  267. PWORD_DEV_HEADER . . . . . . . .    L NEAR     0000    DEV_SEG
  268. REQUEST_PTR. . . . . . . . . . .    L DWORD    0036    DEV_SEG
  269. REQ_PTR_OFF. . . . . . . . . . .    L WORD     0036    DEV_SEG
  270. REQ_PTR_SEQ. . . . . . . . . . .    L WORD     0038    DEV_SEG
  271. RET. . . . . . . . . . . . . . .    L NEAR     00A8    DEV_SEG
  272. STRATEGY . . . . . . . . . . . .    F PROC    0070    DEV_SEG    Length =000B
  273. STRATEGY_PTR . . . . . . . . . .    L WORD     0006    DEV_SEG
  274. TRY_AGAIN. . . . . . . . . . . .    L NEAR     00BC    DEV_SEG
  275.  
  276. Warning Severe
  277. Errors    Errors 
  278. 0    5
  279.